//go:generate goxgen .

//go:build ignore
// +build ignore

package main

import (
	"database/sql"
	"fmt"
)

func GetUsersByStatus(db *sql.DB, status string) {
	// 基础Query语法
	query1 := Query(`SELECT * FROM users WHERE status = #{status}`)
	fmt.Println("Query 1:", query1.String())

	// 带文本插入的Query
	tableName := "users"
	query2 := Query(`SELECT count(*) FROM {tableName}`)
	fmt.Println("Query 2:", query2.String())

	// 条件逻辑
	includeDeleted := false
	query3 := Query(`
		SELECT * FROM users WHERE {
			if includeDeleted {
				return "1=1"
			} else {
				return "deleted_at IS NULL"
			}
		}
	`)
	fmt.Println("Query 3:", query3.String())
}

func main() {
	fmt.Println("新的Query()语法示例")
	GetUsersByStatus(nil, "active")
}
